<?php
class  Front_Model_DbTable_Employee  extends  Zend_Db_Table_Abstract
{
    protected $_name = 'employee' ;
    
    public function validateActive($activeKey, $email){
    	try {
    		$sql = "Select id, status from employee where email = ? and activekey = ?";
    		$db = $this->_db;
    		$db->setFetchMode ( Zend_Db::FETCH_ASSOC );
    		$result = $db->fetchAll ( $sql,array($email, $activeKey) );
    		if(!empty($result)) return $result[0];
    		return $result;
    	} catch ( Exception $ex ) {
    		echo "<br/>Can not validate activekey, Error: " . $ex->getMessage ();
    	}
    }
    
    public function updateStatus($id, $status){
    	try {
    		$data  = array(
		    			'status' =>  $status
		    			);
    		$this->update($data, 'id = '. (int)$id );
    	} catch ( Exception $ex ) {
    		echo "<br/>Can not update status for employee, Error: " . $ex->getMessage ();
    	}
    }
    
    public function  updateData($id, $data)
    {
    	$this->update($data, 'id = '. (int)$id );
    }
    
    public function getEmployeeInfo($id){
    	try {
    		$sql = "Select * from employee where id = ?";
    		$db = $this->_db;
    		$db->setFetchMode ( Zend_Db::FETCH_OBJ );
    		$result = $db->fetchAll ( $sql, array($id));
    		if(!empty($result)) return $result[0];
    		return $result;
    	} catch ( Exception $ex ) {
    		echo "<br/>Can not validate activekey, Error: " . $ex->getMessage ();
    	}
    }
}
